﻿using System;
using System.Collections;
using System.Data;
using System.Data.SqlClient;
using CE.Database;

/// <summary>
/// Summary description for ProposalDownloadDB
/// </summary>
/// 
namespace CE.Provider
{
    public class ProposalDownloadDB
    {
        public ProposalDownloadDB()
        {
            //
            // TODO: Add constructor logic here
            //
        }

        public DataSet GetHSBCProposal(Int64 RefId, string InsuranceType)
        {
            MyDatabase _db = new MyDatabase();
            string _spName = "[sprocProviderProposalSelectItem_Hsbc]";

            SortedList _spara = new SortedList();
            _spara.Add("@RefId", RefId);
            _spara.Add("@InsuranceType", InsuranceType);

            DataSet _ds = _db.GetDataSet(_spName, _spara);

            return _ds;
        }

        public DataSet GetEtiqaProposal(Int64 RefId, string InsuranceType)
        {
            MyDatabase _db = new MyDatabase();
            string _spName = "[sprocProviderProposalSelectItem_Etiqa]";

            SortedList _spara = new SortedList();
            _spara.Add("@RefId", RefId);
            _spara.Add("@InsuranceType", InsuranceType);

            DataSet _ds = _db.GetDataSet(_spName, _spara);

            return _ds;
        }

        public DataSet GetLMGProposal(Int64 RefId, string InsuranceType)
        {
            MyDatabase _db = new MyDatabase();
            string _spName = "[sprocProviderProposalSelectItem_LMG]";

            SortedList _spara = new SortedList();
            _spara.Add("@RefId", RefId);
            _spara.Add("@InsuranceType", InsuranceType);

            DataSet _ds = _db.GetDataSet(_spName, _spara);

            return _ds;
        }

        public DataSet GetAZCpProposal(Int64 RefId, string InsuranceType)
        {
            MyDatabase _db = new MyDatabase();
            string _spName = "[sprocProviderProposalSelectItem_AZCp]";

            SortedList _spara = new SortedList();
            _spara.Add("@RefId", RefId);
            _spara.Add("@InsuranceType", InsuranceType);

            DataSet _ds = _db.GetDataSet(_spName, _spara);

            return _ds;
        }

        public DataSet GetMSIGProposal(Int64 RefId, string InsuranceType)
        {
            MyDatabase _db = new MyDatabase();
            string _spName = "[sprocProviderProposalSelectItem_MSIG]";

            SortedList _spara = new SortedList();
            _spara.Add("@RefId", RefId);
            _spara.Add("@InsuranceType", InsuranceType);

            DataSet _ds = _db.GetDataSet(_spName, _spara);

            return _ds;
        }

        public DataSet GetBKIProposal(Int64 RefId, string InsuranceType)
        {
            MyDatabase _db = new MyDatabase();
            string _spName = "[sprocProviderProposalSelectItem_BKI]";

            SortedList _spara = new SortedList();
            _spara.Add("@RefId", RefId);
            _spara.Add("@InsuranceType", InsuranceType);

            DataSet _ds = _db.GetDataSet(_spName, _spara);

            return _ds;
        }

        public DataSet GetHSBCProposalPDF(Int64 RefId, string InsuranceType)
        {
            MyDatabase _db = new MyDatabase();
            string _spName = "[sprocProviderProposalSelectItemPDF_Hsbc]";

            SortedList _spara = new SortedList();
            _spara.Add("@RefId", RefId);
            _spara.Add("@InsuranceType", InsuranceType);

            DataSet _ds = _db.GetDataSet(_spName, _spara);

            return _ds;
        }

        public DataSet GetPaymentDetails(Int64 RefId, Int64 ProviderCompanyId, string InsuranceType) //Sakthi
        {
            MyDatabase _db = new MyDatabase("TH.CX_DB_Payment_ConnectionString");
            string _spName = "[sprocPaymentDetailSelectSingleItem]";

            SortedList _spara = new SortedList();
            _spara.Add("@RefId", RefId);
            _spara.Add("@ProviderCompanyId", ProviderCompanyId);
            _spara.Add("@InsuranceType", InsuranceType);

            DataSet _ds = _db.GetDataSet(_spName, _spara);

            return _ds;
        }

        public DataSet GetAllProposal(string ProviderCompanyId, string InsuranceType, int ReportType, string ReportDate1, string ReportDate2)
        {
            MyDatabase _db = new MyDatabase();
            string _spName = "[sprocProviderProposalItemList]";

            SortedList _spara = new SortedList();
            _spara.Add("@ProviderCompanyId", ProviderCompanyId);
            _spara.Add("@InsuranceType", InsuranceType);
            _spara.Add("@ReportType", ReportType);
            _spara.Add("@ReportDate1", ReportDate1);
            _spara.Add("@ReportDate2", ReportDate2);

            DataSet _ds = _db.GetDataSet(_spName, _spara);

            return _ds;
        }

        public DataSet GetPADownloadInfo(Int64 RefId, Int64 ProviderCompanyId)
        {
            MyDatabase _db = new MyDatabase();
            string _spName = "[sprocPAProposalSelectDownloadInfo]";

            SortedList _spara = new SortedList();
            _spara.Add("@PAId", RefId);
            _spara.Add("@ProviderCompanyId", ProviderCompanyId);

            DataSet _ds = _db.GetDataSet(_spName, _spara);

            return _ds;
        }

        public DataSet GetTIDownloadInfo(Int64 RefId, Int64 ProviderCompanyId)
        {
            MyDatabase _db = new MyDatabase();
            string _spName = "[sprocTAMoreDetailSelectDownloadInfo]";

            SortedList _spara = new SortedList();
            _spara.Add("@CETAId", RefId); //Info2 or TAAppSeaId
            _spara.Add("@ProviderCompanyId", ProviderCompanyId);

            DataSet _ds = _db.GetDataSet(_spName, _spara);

            return _ds;
        }

        public DataSet GetCarDownloadInfo(Int64 RefId, Int64 ProviderCompanyId)
        {
            MyDatabase _db = new MyDatabase();
            string _spName = "[sprocCarMoreDetailSelectDownloadInfo]";

            SortedList _spara = new SortedList();
            _spara.Add("@CECarId", RefId);
            _spara.Add("@ProviderCompanyId", ProviderCompanyId);

            DataSet _ds = _db.GetDataSet(_spName, _spara);

            return _ds;
        }

        public Int64 UpdatePADownloadInfo(Int64 RefId, Int64 ProviderCompanyId, Boolean IsDownload, Boolean IsDownloadConfirm, Int32 DownloadCount, Int64 DownloadId, Int64 RefCEUserId)
        {
            MyDatabase _db = new MyDatabase();
            Int64 _result = -1;
            string _spName = "[sprocPAProposalUpdateDownloadInfo]";

            SortedList _sPara = new SortedList();

            #region Parameter
            _sPara.Add("@PAId", RefId);
            _sPara.Add("@ProviderCompanyId", ProviderCompanyId);
            _sPara.Add("@IsDownload", IsDownload);
            _sPara.Add("@IsDownloadConfirm", IsDownloadConfirm);
            _sPara.Add("@DownloadCount", DownloadCount);
            _sPara.Add("@DownloadId", DownloadId);
            _sPara.Add("@RefCEUserId", RefCEUserId);
            #endregion

            _result = _db.ExecuteSP(_spName, _sPara);

            return _result;
        }

        public Int64 UpdateTIDownloadInfo(Int64 RefId, Int64 ProviderCompanyId, Boolean IsDownload, Boolean IsDownloadConfirm, Int32 DownloadCount, Int64 DownloadId, Int64 RefCEUserId)
        {
            MyDatabase _db = new MyDatabase();
            Int64 _result = -1;
            string _spName = "[sprocTAMoreDetailUpdateDownloadInfo]";

            SortedList _sPara = new SortedList();

            #region Parameter
            _sPara.Add("@CETAId", RefId);
            _sPara.Add("@ProviderCompanyId", ProviderCompanyId);
            _sPara.Add("@IsDownload", IsDownload);
            _sPara.Add("@IsDownloadConfirm", IsDownloadConfirm);
            _sPara.Add("@DownloadCount", DownloadCount);
            _sPara.Add("@DownloadId", DownloadId);
            _sPara.Add("@RefCEUserId", RefCEUserId);
            #endregion

            _result = _db.ExecuteSP(_spName, _sPara);

            return _result;
        }

        public Int64 UpdateCarDownloadInfo(Int64 RefId, Int64 ProviderCompanyId, Boolean IsDownload, Boolean IsDownloadConfirm, Int32 DownloadCount, Int64 DownloadId, Int64 RefCEUserId)
        {
            MyDatabase _db = new MyDatabase();
            Int64 _result = -1;
            string _spName = "[sprocCarMoreDetailUpdateDownloadInfo]";

            SortedList _sPara = new SortedList();

            #region Parameter
            _sPara.Add("@CECarId", RefId);
            _sPara.Add("@ProviderCompanyId", ProviderCompanyId);
            _sPara.Add("@IsDownload", IsDownload);
            _sPara.Add("@IsDownloadConfirm", IsDownloadConfirm);
            _sPara.Add("@DownloadCount", DownloadCount);
            _sPara.Add("@DownloadId", DownloadId);
            _sPara.Add("@RefCEUserId", RefCEUserId);
            #endregion

            _result = _db.ExecuteSP(_spName, _sPara);

            return _result;
        }
    }
}